home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / 4dostool / mav120.zip / MAV.BTM < prev   
Text File  |  1992-10-29  |  12KB  |  357 lines

  1. @echo off
  2. setlocal
  3. unalias *
  4. goto env_space
  5.  
  6. :          ┌───────────────────── Information ──────────────────────┐
  7. :          │                                                        │
  8. :          │  This is Mally's Archive Viewer. The purpose of this   │
  9. :          │  program is to facilitate viewing the contents of a    │
  10. :          │  so called archive without having to remember the      │
  11. :          │  parameters and without having to clean up the mess    │
  12. :          │  after you finish.                                     │
  13. :          │                                                        │
  14. :          │  This is a Batch To Memory (btm) file,                 │
  15. :          │  which means that it is a very fast batch file that    │
  16. :          │  will only run if 4DOS is your command interpreter.    │
  17. :          │  Moreover, it is assumed that you use 4DOS version     │
  18. :          │  4.0 or later. 4DOS is a shareware program, available  │
  19. :          │  at almost every BBS and `anonymous FTP' site.         │
  20. :          │                                                        │
  21. :          │  Of course, you are free to make as many changes in    │
  22. :          │  this program as you like. If you do, please change    │
  23. :          │  the name of the file and remove my name (%MYNAME).    │
  24. :          │                                                        │
  25. :          │  If you have any remarks, questions or suggestions,    │
  26. :          │  E-mail me at                                          │
  27. :          │                   MALLY@eco.rug.nl                     │
  28. :          │                                                        │
  29. :          └────────────────────────────────────────────────────────┘
  30.  
  31. :installation
  32.  
  33. :          ┌───────────────────── Installation ─────────────────────┐
  34. :          │                                                        │
  35. :          │  Fill in the path to your archivers, e.g.              │
  36.                 set ARCPATH=y:;g:\utils\zip;g:\utils\arj
  37. :          │  (Only needed if not already in path)                  │
  38. :          │                                                        │
  39. :          │  Fill in the archive extensions known to your system   │
  40. :          │  ( any of [arc,arj,lzh,zip,zoo] ), e.g.                │
  41.                 set ARCTYPES=arc;arj;lzh;zip;zoo
  42. :          │  MAV uses the following programs to handle archives:   │
  43. :          │    arc : PKUNPAK      (PKWARE Inc.)                    │
  44. :          │    arj : ARJ          (Robert K. Jung)                 │
  45. :          │    lzh : LHA          (Haruyasu Yoshizaki)             │
  46. :          │    zip : PKUNZIP      (PKWARE Inc.)                    │
  47. :          │    zoo : ZOO          (Rahul Dhesi)                    │
  48. :          │                                                        │
  49. :          │  Fill in the working directory, i.e. the directory     │
  50. :          │  where some temporary files will be written            │
  51.                 set WORKINGDIR=g:\mav
  52. :          │                                                        │
  53. :          │  Define the parameter DOCU, i.e. indicate the          │
  54. :          │  files to `show only' if this parameter is used        │
  55.                 set DOCU=*.doc *.txt *.me *.man *.bat *.btm
  56. :          │                                                        │
  57. :          │  Colors used in selection windows are set by the       │
  58. :          │  HistWinColor directive in 4DOS.INI.                   │
  59. :          │                                                        │
  60. :          └────────────────────────────────────────────────────────┘
  61.  
  62. :          ┌────────────────────── History ─────────────────────────┐
  63. :          │                                                        │
  64. :          │  v1.2  Changed name to MAV.                            │
  65. :          │        Minimized amount of free environment space      │
  66. :          │        needed at start-up.                             │
  67. :          │        Check on existence of WORKINGDIR added.         │
  68. :          │        Can now handle full pathnames in ZIP files.     │
  69. :          │        Parameter DOCU added.                           │
  70. :          │  v1.1  Several improvements. Donated to the            │
  71. :          │        public domain.                                  │
  72. :          │  v1.02 Changed listing technique of archives           │
  73. :          │        (much faster)                                   │
  74. :          │  v1.01 Minor alterations and bug fixes                 │
  75. :          │  v1.00 First release for very small public             │
  76. :          │                                                        │
  77. :          └────────────────────────────────────────────────────────┘
  78.  
  79. goto continue
  80.  
  81. :env_space
  82. : This is a trick to assure enough environment space under almost all
  83. : circumstances. MAV needs 20 bytes of environment space to start but
  84. : approximately 512 bytes to run. If not enough space is available,
  85. : MAV reloads itself in a secondary shell.
  86. : Under exceptional circumstances it is possible that 512 bytes are not 
  87. : enough to run. The solution is to increase the value of ES, set below.
  88.   if %_env LT 20 goto error_memory
  89.   set ES=512 >& nul
  90.   if "%1"=="/run" goto installation
  91.   if %_env GE %ES goto installation
  92.   %COMSPEC //EnvFree=%ES /c %0 /run %& >&> nul
  93.   goto end
  94.  
  95. :continue
  96.  
  97. set VERSION=v1.2
  98. set MYNAME=Mally
  99. iff "%1"=="/run" then
  100.   if %#==1 goto syntax
  101.   shift 1
  102. else
  103.   if %#==0 goto syntax
  104. endiff
  105.  
  106.  
  107. if "%_4ver"=="" set _4ver=0
  108. iff %_4ver LT 4.0 then
  109.   echo.
  110.   echo   Sorry, need 4DOS version 4.0 or higher to run.
  111.   goto end
  112. endiff
  113.  
  114. keystack !
  115.  
  116. if "%ARCPATH" NE "" path %ARCPATH%;%PATH%
  117.  
  118. set ARCHIVE=%1
  119. iff %@eval[%@index[%ARCHIVE,.]+1]==%@len[%ARCHIVE] then
  120.   set ARCHIVE=%@substr[%ARCHIVE,0,%@index[%ARCHIVE,.]]*.*
  121. endiff
  122.  
  123. set SHOWONLY=%2&
  124. if "%@upper[%SHOWONLY]"=="DOCU" set SHOWONLY=%DOCU
  125.  
  126. if "%@substr[%WORKINGDIR,0,-1]" NE "\" set WORKINGDIR=%WORKINGDIR%\
  127. iff NOT isdir %WORKINGDIR then
  128.   echo.
  129.   echo The working directory %@upper[%WORKINGDIR] does not exist.
  130.   inkey /K"YyNn" Should it be created? (y/n) %%CHAR
  131.   iff "%@upper[%CHAR]"=="N" then
  132.     echo Directory NOT created.
  133.     shift -1
  134.     echo See file %@upper[%@search[%0]] for installation directives.
  135.     quit
  136.   endiff
  137.   md %WORKINGDIR
  138. endiff
  139.  
  140. set LIST=%@unique[%WORKINGDIR]
  141. set LISTING=%@unique[%WORKINGDIR]
  142. set DELFILES=%LIST %LISTING
  143.  
  144. pushd
  145. cdd %@path[%ARCHIVE] >& NUL
  146. set ARCDIR=%_cwds
  147.  
  148. set ARCHIVE=%@name[%ARCHIVE]%.%@ext[%ARCHIVE]
  149. if "%@ext[%ARCHIVE]"=="*" set ARCHIVE=%@name[%ARCHIVE]
  150. iff "%@ext[%ARCHIVE]"=="" then
  151.   if %@index[%ARCTYPES%,arc] GE 0 set ATYPES=%ARCHIVE%.arc;
  152.   if %@index[%ARCTYPES%,arj] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.arj;
  153.   if %@index[%ARCTYPES%,lzh] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.lzh;
  154.   if %@index[%ARCTYPES%,zip] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.zip;
  155.   if %@index[%ARCTYPES%,zoo] GE 0 set ATYPES=%ATYPES%%ARCHIVE%.zoo;
  156.   set ARCTYPES=%ATYPES%
  157.   set ATYPES=
  158.   dir %ARCTYPES /bfOn > %LISTING >&> NUL
  159. else
  160.   dir %ARCHIVE /bfOn > %LISTING >&> NUL
  161. endiff
  162.  
  163.  
  164. :more
  165.   iff %@lines[%LISTING] GE 1 then
  166.     set ARCHIVE=%@select[%LISTING,0,0,25,80, Mally's Archive Viewer %VERSION ]
  167.     set MORE=more
  168.   else
  169.     set ARCHIVE=%@line[%LISTING,0]
  170.   endiff
  171.  
  172.   if "%ARCHIVE"=="" goto thanks
  173.   if "%ARCHIVE"=="**EOF**" goto no_archives
  174.   if "%ARCHIVE"=="*.*" goto no_archives
  175.  
  176. iff "%@ext[%ARCHIVE]"=="arc" then
  177.   set ARCHIVER=pkunpak
  178.   set VIEW=-v
  179.   set POSITION=0
  180.   set LENGTH=,13
  181.   set EXTRACT=-e
  182.   set KEYSTACK=down down down down down down down down
  183.   goto main
  184. endiff
  185.  
  186. iff "%@ext[%ARCHIVE]"=="arj" then
  187.   set ARCHIVER=arj
  188.   set VIEW=l
  189.   set POSITION=0
  190.   set LENGTH=,13
  191.   set EXTRACT=e
  192.   set KEYSTACK=down down down down down down down
  193.   goto main
  194. endiff
  195.  
  196. iff "%@ext[%ARCHIVE]"=="lzh" then
  197.   set ARCHIVER=lha
  198.   set VIEW=-l
  199.   set POSITION=2
  200.   set LENGTH=,13
  201.   set EXTRACT=e
  202.   set KEYSTACK=down down down down down
  203.   goto main
  204. endiff
  205.  
  206. iff "%@ext[%ARCHIVE]"=="zip" then
  207.   set ARCHIVER=pkunzip
  208.   set VIEW=-v
  209.